#!/usr/bin/env node

var timer1,tumer2;
var count=0;

timer1=setInterval(function(){
  console.log("timer1:I will loop forever");
},500);

setTimeout(function(){
  clearInterval(timer1);
  console.log('timer1 over!')
  timer2=setInterval(function(){
    console.log('timer2:I will loop five times');
    count++;
    if(5==count){
      clearInterval(timer2);
      console.log("timer2 over!!");
    }
  },500)
},3000);


//第三种自动销毁
/*
var timer3=setInterval(loop,500);
timer3.unref();
function loop(){
  console.log('I am timer3');
}
setTimeout(()=>{
  console.log('timer3 over!!!');
},3000);
*/
